package com.android.djlmapp.js_interface;

import android.app.Activity;
import android.content.Intent;

import com.android.djlmapp.activity.home.web.ForgetPwdActivity;
import com.android.djlmapp.activity.recharge.AddMoneyActivity;
import com.just.agentweb.AgentWeb;

/**
 * @Author wangziheng
 * @ProjectName djlm
 * @ClassName AbJsInterfaceCallBack
 * @package com.android.djlmapp.jsInterface
 * @data 2018/12/24 12:25
 * @Describe js交互监听
 * @Change
 */
public abstract class AbJsInterfaceCallBack {
    /**
     * 	 1,NativeGoOrder 去订单列表
     * 		 2,NativeGoBack 回退
     * 		 3,NativeCloseWindow 关闭窗口
     * 		 4,NativeScanSim 扫描SIM卡号 返回 SIM卡号 string
     * 		 5,NativeGetPhonenum 搜索号码 返回  所选号码 string
     * 		 6,NativeGetImage  获取照片  返回 上传照片接口返回的参数 object
     * 		 7,NativeGetSign   获取签名  返回 上传照片接口返回的参数 object
     */


    /**
     * 关闭当前Activity
     */
    public void finishActivityFromJs(Activity activity, AgentWeb agentWeb) {
        if (agentWeb != null && activity != null && !activity.isDestroyed() && !activity.isFinishing()) {
            activity.finish();
        }
    }

    /**
     * webview回退
     */
    public void finishWebPageFromJs(Activity activity, AgentWeb agentWeb) {
        if (agentWeb != null && !agentWeb.back()) {
            finishActivityFromJs(activity, agentWeb);
        }
    }

    /**
     * 前往加款界面
     */
    public void goRechargeMoney(Activity activity) {
        if (activity != null) {
            activity.startActivity(new Intent(activity, AddMoneyActivity.class));
        }
    }

    /**
     * 忘记密码
     */
    public void forgetPsw(Activity activity){
        if(activity != null){
            activity.startActivity(new Intent(activity, ForgetPwdActivity.class));
        }
    }

}
